-----------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/juanpablouribetrujillo/My Drive (jp.uribe86@gmail.com)/Research/MyPapers/MTU/JUE/analys
> is/../logs/sample_regressions.log
  log type:  text
 opened on:  24 Jun 2024, 22:21:08

. *-------------------------****** OUTPUT SETTINGS *****---------------------;
. *settings some settings that are common for the set of plots on this dofile;
.  local pdf_plot_settings =      `"scale(*1.5) ymtick(##4) "';

. *settings for latex tables ;
.                 global prehead_start "prehead(\begin{table}[H]\centering 
>                 \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  
>                 \caption{@title}
>                 \setlength{\tabcolsep}{1pt}";

.                                 global prehead_start_longcol "prehead(\begin{table}[!htb]\centering 
>                 \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  
>                 \caption{@title}
>                 \setlength{\tabcolsep}{6pt}";

.                                 local font_size "";

.                 global prehead_end         "\begin{tabular}{l*{@span}{c}}\hline\hline)";

.                 global prehead_end_bigskip "\begin{tabular}{l*{@span}{c}}\hline\hline \bigskip\\[6ex])";

.                 global postfoot "postfoot(\hline\hline
>                 \multicolumn{@span}{l}{\footnotesize Standard Errors in Parentheses Clustered at the Stat
> e-Year Level. }\\
>                         \multicolumn{@span}{l}{\footnotesize  @starlegend. }
>                 \end{tabular}\end{table})";

.                                                                                                         l
> ocal tex_settigns  = `"
>                 ${prehead_start}
>                 `font_size'
>                 ${prehead_end}
>                 ${postfoot}
>                 "';

.         *----------------------------------------------------------------------------------;
. use "../data/hpms_hwy_stats_88_08.dta", clear  ;

. *---------------------------------------------------;
. * - Generate variables and general cleanings ;
. *---------------------------------------------------;
. do "_programs_sample";

. # d ;
delimiter now ;
. ****************************************;
.         *This program is used to add a row indicating the use of sample id when using areg;
. cap program drop add_lab_FE;

. program define add_lab_FE;
  1.         matrix V = [vecdiag(e(V)),1];
  2.         matrix V=diag(V);
  3.         matrix b=[e(b),1];
  4.         matrix colnames b= `:  colnames e(b)' `1';
  5.         matrix colnames V= `:  colnames e(V)' `1';
  6.         erepost b=b V=V ,rename;
  7. end;

. ****************************************;
.         *This program calculates summary stats for regression tables;
. cap program drop sum_stats;

. program define sum_stats;
  1.         sum Diri ;
  2.         estadd  scalar mean_Diri=r(mean) ;
  3.         sum aadt_10000  ;
  4.         estadd  scalar mean_aadt=r(mean) ;
  5.         sum I2_t ;
  6.         estadd  scalar mean_I2_t=r(mean) ;
  7.         sum I2_t_exp_I2  ;
  8.         estadd  scalar mean_I2_t_exp=r(mean) ;
  9.         end;

. ****************************************;
.         *This program plots year dummies;
. cap program drop plot_dummies;

. program define plot_dummies;
  1.         preserve;
  2.         *save se to disk;
.         mata: se=sqrt(diagonal(st_matrix("e(V)")));
  3.  // converts e(V) into se and placed in mata matrix se
>         clear;
  4.         getmata se, force ;
  5.         gen counter=_n;
  6.         save se,replace;
  7.                 *save coefficients to disk and organize;
.         mat beta=e(b);
  8.         mat list beta;
  9.         clear;
 10.         set obs 1;
 11.         svmat double beta;
 12.         *file in memory is a single row year effects from regression;
.         gen dummy=1;
 13.         reshape long beta,  i(dummy) j(year);
 14.         gen counter=_n;
 15.         *merge with se;
.         merge 1:1 counter using se;
 16.         drop if counter>17;
 17.         drop if beta==. | beta==0;
 18.         drop _merge counter;
 19.         *just keep year X expenditure coefficients;
.         drop if year==.;
 20.         replace year = year+1991;
 21.         sort year;
 22.         *file in memory gives bin, mean y and se;
.         gen up5 = beta+1.96*se;
 23.         gen down5 = beta-1.96*se;
 24.         save beta, replace;
 25.         *file in memory is a list of year by year inverse prices and CI's;
.         *settings for plots;
.         local pdf_plot_settings =       `"bgcolor(white) 
>                                         graphregion(color(white)) plotregion(ls(none))  
>                                                                 xmtick(1992(1)2008) 
>                                                                 ymtick(##5)
>                                                                 xlabel(1992(4)2008)
>                                         xtitle("")
>                                         legend(off)
>                                         scale(*1.5)
>                                         
>                                         "';
 26.                                         twoway rcap up5 down5 year, lstyle(ci)|| scatter beta year, `p
> df_plot_settings';
 27.         graph export "temp_t.pdf", replace;
 28.         erase se.dta;
 29.         erase beta.dta;
 30.         save "temp_betas.dta", replace;
 31.         restore;
 32. end;

. # d ;
delimiter now ;
. cap program drop plot_dummies_cons;

. program define plot_dummies_cons;
  1. args y_var controls;
  2.         matrix time_cons=J(17,3,.);
  3.         matrix colnames time_cons=year beta var;
  4.         local n=1;
  5.                 if "`controls'"==""{;
  6.                 forvalues year=1992(1)2008{;
  7.                                 reg `y_var' I2_t_x* ,  cluster(state);
  8.                                 nlcom _b[I2_t_x`year']+_b[_cons], post;
  9.                                 mat  time_cons[`n',1]=`year';
 10.                                 mat  time_cons[`n',2]=e(b);
 11.                                 mat  time_cons[`n',3]=e(V);
 12.                                 local n=`n'+1;
 13.                 }               ;
 14.         };
 15.                                         if "`controls'"=="state"{;
 16.                 forvalues year=1992(1)2008{;
 17.                                                                 areg Diri  I2_t_x*   ,  cluster(state)
>  abs(state ) ;
 18. ;
.                                 nlcom _b[I2_t_x`year']+_b[_cons], post;
 19.                                 mat  time_cons[`n',1]=`year';
 20.                                 mat  time_cons[`n',2]=e(b);
 21.                                 mat  time_cons[`n',3]=e(V);
 22.                                 local n=`n'+1;
 23.                 }               ;
 24.         };
 25.                                 if "`controls'"=="id"{;
 26.                 forvalues year=1992(1)2008{;
 27.                                                                 areg Diri  I2_t_x*   ,  cluster(state)
>  abs(id) ;
 28.                                 nlcom _b[I2_t_x`year']+_b[_cons], post;
 29.                                 mat  time_cons[`n',1]=`year';
 30.                                 mat  time_cons[`n',2]=e(b);
 31.                                 mat  time_cons[`n',3]=e(V);
 32.                                 local n=`n'+1;
 33.                 }               ;
 34.         };
 35.                                         preserve ;
 36.                                 clear ;
 37.                                 svmat time_cons, names(col) ;
 38.                                 gen se=var^(1/2);
 39.                                 gen up5 = beta+1.96*se;
 40.                                 gen down5 = beta-1.96*se;
 41.                                 save beta`y_var', replace;
 42.                                 *file in memory is a list of year by year inverse prices and CI's;
.                                 *settings for plots;
.                                 local pdf_plot_settings =       `"bgcolor(white) 
>                                                                 graphregion(color(white)) plotregion(ls(n
> one))  
>                                                                 xmtick(1992(1)2008) 
>                                                                 ymtick(##5)
>                                                                 xlabel(1992(4)2008)
>                                                                 legend(off)
>                                                                 xtitle("")
>                                                                 
>                                                                 scale(*1.5)"';
 43.                                 twoway rcap up5 down5 year, lstyle(ci)|| scatter beta year, `pdf_plot_
> settings';
 44.                                 graph export "temp_t.pdf", replace;
 45.                                                                                         restore ;
 46. end;

. # d cr ;
delimiter now cr
. 
. 
end of do-file

. do "_setup_expenditure.do";

. /******************************************************************
> 
> setup_expenditure.do
> 
> Subroutine to calculate expenditure variables for all analysis programs;
> 
> mt 20190506
> *******************************************************************/
. # delim ;  
delimiter now ;
. * expenditure on length and IRI from SF12a. Check that categories are right. Can we break apart ROW?;
. *conversion factor to get to 10^6 2010 dollars;
. gen deflate= 1/(ppiaco_2010*10);

. *gen deflate= 1;
. *consolidate rural and urban SF12a variables that we need;
. local rur_urb_list      "exp_eng_row_IH                 exp_row_IH              exp_eng_IH              e
> xp_new_cons_IH
>                         exp_relocation_IH               exp_recons_IH           exp_recons_add_IH       e
> xp_recons_noadd_IH
>                         exp_maj_wide_IH                 exp_R3_IH               exp_R3_min_wide_IH      e
> xp_R3_rehab_rest_IH    
>                         exp_R3_resurf_IH
>                         exp_new_bridge_IH exp_bridgereplacement_IH exp_majorbridgerehab_IH exp_minorbridg
> erehab_IH exp_bridge_IH
>                         ";

. foreach exp_var of local rur_urb_list{;
  2.                 replace `exp_var'_urban=cond(`exp_var'_urban==.,0,`exp_var'_urban);
  3.                 replace `exp_var'_rural=cond(`exp_var'_rural==.,0,`exp_var'_rural);
  4.                 gen `exp_var'_all = `exp_var'_urban + `exp_var'_rural;
  5.                 drop `exp_var'_urban `exp_var'_rural;
  6.                 };
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)
(889 real changes made)
(735 real changes made)

. *consolidate SF12a variables into nominal construction and resurfacing for pre and post 1998;
. *NB: exp_new_cons_IH_all and exp_maj_wide_IH_all are common to pre and post 1998 construction;
. gen exp_L_IH_SF12a_n_old=       exp_eng_row_IH_all + exp_new_cons_IH_all + exp_maj_wide_IH_all;

. gen exp_IRI_IH_SF12a_n_old=     exp_recons_IH_all  + exp_R3_IH_all;

.  gen exp_L_IH_SF12a_n_new=      exp_row_IH_all     + exp_eng_IH_all      + exp_new_cons_IH_all  + exp_rel
> ocation_IH_all + exp_maj_wide_IH_all;

.                         gen exp_IRI_IH_SF12a_n_new=     exp_recons_add_IH  + exp_recons_noadd_IH + exp_R3
> _min_wide_IH   + exp_R3_rehab_rest_IH  + exp_R3_resurf_IH;

. * Do the same for bridge expenditure ;
. gen exp_bridge_IH_SF12a_n_new=cond( year>1998,
>                                                                         exp_new_bridge_IH_all+exp_bridger
> eplacement_IH_all+exp_majorbridgerehab_IH_all+exp_minorbridgerehab_IH_all,.);
(147,240 missing values generated)

.                                                                         gen exp_bridge_IH_SF12a_n_old=con
> d( year<=1998,
>                                                                         exp_bridge_IH_all,.);
(160,858 missing values generated)

. *diagnostics -- should all be zero -- this test won't work for construction;
. sum exp_IRI_IH_SF12a_n_new exp_IRI_IH_SF12a_n_old if year>1998;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
exp_IRI_IH~w |    160,858    220065.6      226117          0    1142287
exp_IRI_IH~d |    160,858           0           0          0          0

. sum exp_IRI_IH_SF12a_n_new exp_IRI_IH_SF12a_n_old if year<=1998;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
exp_IRI_IH~w |    147,240           0           0          0          0
exp_IRI_IH~d |    147,240      107408      108656          0     560136

. *consolidate pre and post 1998 variable construction;
. gen exp_IRI_IH_SF12a_n =        cond(year>1998, exp_IRI_IH_SF12a_n_new, exp_IRI_IH_SF12a_n_old);

. gen exp_L_IH_SF12a_n =          cond(year>1998, exp_L_IH_SF12a_n_new, exp_L_IH_SF12a_n_old);

. gen exp_bridge_IH_SF12a_n =             cond(year>1998, exp_bridge_IH_SF12a_n_new, exp_bridge_IH_SF12a_n_
> old);

. *clean up -- save reloacation;
. gen temp = exp_relocation_IH_all;

. gen temp2 =exp_row_IH_all ;

. foreach exp_var of local rur_urb_list{;
  2.                 drop `exp_var'_all;
  3.                 };

.                 drop *_new *_old;

. rename temp exp_relocation_IH_all_n;

.  rename temp2 exp_row_IH_all_n ;

. *calculate total IH and SF12a maintenance;
. gen exp_IH_total_SF12_n = exp_IH_mtn_all + exp_IH_k_all;
(351 missing values generated)

. gen exp_IH_mtn_SF12a_n = exp_IH_total_SF12_n - exp_IRI_IH_SF12a_n - exp_L_IH_SF12a_n -exp_bridge_IH_SF12a
> _n;
(351 missing values generated)

. sum exp_IH_mtn_SF12a_n, d ;

                     exp_IH_mtn_SF12a_n
-------------------------------------------------------------
      Percentiles      Smallest
 1%       -73065        -796329
 5%         4228        -796329
10%     7764.049        -796329       Obs             307,747
25%        19215        -796329       Sum of wgt.     307,747

50%        48833                      Mean           75766.26
                        Largest       Std. dev.      104646.2
75%     100944.5        2017193
90%     181282.9        2062267       Variance       1.10e+10
95%     237426.6        3278198       Skewness       2.799105
99%       458010        3303381       Kurtosis       40.18784

. replace exp_IH_mtn_SF12a_n= cond(exp_IH_mtn_SF12a_n<0,0,exp_IH_mtn_SF12a_n );
(5,948 real changes made)

. sum exp_IH_mtn_SF12a_n, d ;

                     exp_IH_mtn_SF12a_n
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%         4228              0
10%     7764.049              0       Obs             307,747
25%        19215              0       Sum of wgt.     307,747

50%        48833                      Mean            78426.6
                        Largest       Std. dev.      97296.26
75%     100944.5        2017193
90%     181282.9        2062267       Variance       9.47e+09
95%     237426.6        3278198       Skewness       4.440624
99%       458010        3303381       Kurtosis       45.17407

. ;
. *convert to real 2010 USD 10^6;
. *NB: deflate calculated in calling program;
. rename app_IH app_IH_n;

. rename exp_IH_mtn_all exp_IH_mtn_SF12_n;

. ren rev_grand_total_mt rev_grand_total_mt_n;

. ren rev_total_h rev_total_h_n;

. ren rev_total_mt rev_total_mt_n ;

. ren rev_total_m_fuel_h rev_total_m_fuel_h_n ;

. local real_list "exp_IH_total_SF12 exp_IH_mtn_SF12a exp_IRI_IH_SF12a exp_L_IH_SF12a app_IH exp_IH_mtn_SF1
> 2 exp_relocation_IH_all 
>                                  rev_grand_total_mt rev_total_h rev_total_mt rev_total_m_fuel_h
>                                  exp_bridge_IH_SF12a exp_row_IH_all
>                                  ";

. foreach exp_var of local real_list{;
  2.                 gen `exp_var'_r=deflate*`exp_var'_n;
  3.                 drop `exp_var'_n;
  4.                 };
(351 missing values generated)
(351 missing values generated)
(77,386 missing values generated)
(351 missing values generated)
(105,706 missing values generated)
(399 missing values generated)
(105,706 missing values generated)
(399 missing values generated)

.         forvalues i=1(1)5{;
  2.                                 gen deflate_L`i'= 1/(ppiaco_2010_L`i'*10);
  3.                 ren L`i'FHWA_apport_LW L`i'FHWA_apport_LW_n;
  4.                 gen L`i'FHWA_apport_LW_r=deflate_L`i'*L`i'FHWA_apport_LW_n;
  5.                 drop L`i'FHWA_apport_LW_n;
  6. };
(303 missing values generated)
(351 missing values generated)
(399 missing values generated)
(447 missing values generated)
(495 missing values generated)

.                                                 *label and drop superflous expenditure data;
. label var       exp_IH_total_SF12_r     "Total IH exp SF12 real";

. label var       exp_IH_mtn_SF12_r       "Total IH maint exp SF12 real";

. label var       exp_IH_mtn_SF12a_r      "Total IH maint exp SF12a real";

.  label var      exp_IRI_IH_SF12a_r      "Total IH IRI exp SF12a real";

.  label var      exp_L_IH_SF12a_r        "Total IH L exp SF12a real";

. label var       app_IH_r                "Total IH approp real";

. label var       exp_relocation_IH_all   "Total IH exp relocation, >1998";

. label var   rev_grand_total_mt_r          "Total revenue mass transit account real [source: FE9 p2 ]";

. label var   rev_total_mt_r        "Total revenue highway and mass transit account real [source: FE9 p2 ]"
> ;

. label var   rev_total_h  "Total revenue highway account real [source: FE9 p2 ]";

. label var rev_total_m_fuel_h                     "Total Revenue motor fuel  (Highway motor fuel) [source:
>  FE9 p1 ]";

.         *drop exp_IH_k_rural-exp_subtotal_mtn_urban;
. exit;

end of do-file

. do "_cleaning_and_new_variables_sample.do";

. # d ;
delimiter now ;
. *label variables to mathc the names in the tables ;
. label var exp_L_IH_SF12a_r "\( Y^L \)";

. label var  exp_IRI_IH_SF12a_r "\( Y^L\:in\:IRI \)";

. label var  exp_IH_mtn_SF12a_r "\( Y^L\: in\: Maint.\)";

. ****************************************************;
. *calculate differences in miles and IRI;
. *local D_vars "u_iri_IH u_iri_urban u_iri_rural u_lane_miles_IH u_lane_miles_rural u_lane_miles_urban";
. local D_vars iri ;

. sort state id year ;

. foreach varname of local D_vars{;
  2.         *changed from leads to lags, 20190429;
.         gen D`varname'=cond(
>                         id[_n]==id[_n-1]&
>                         state[_n]==state[_n-1]&
>                         `varname'[_n]!=.&`varname'[_n-1]!=.&
>                         `varname'[_n]!=0&`varname'[_n-1]!=0&
>                         year[_n]==year[_n-1]+1,
>                         `varname'[_n]-`varname'[_n-1],.);
  3.         gen lag_`varname'=cond(
>                         id[_n]==id[_n-1]&
>                         state[_n]==state[_n-1]&
>                         `varname'[_n]!=.&`varname'[_n-1]!=.&
>                         `varname'[_n]!=0&`varname'[_n-1]!=0&
>                         year[_n]==year[_n-1]+1,
>                         `varname'[_n-1],.);
  4.                                         };
(44,521 missing values generated)
(44,521 missing values generated)

. sum Diri d_iri;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    263,577   -1.215084    28.56901       -554        592
       d_iri |    263,577   -1.215084    28.56901       -554        592

.         drop d_iri;

. ** indicator for states with maintenance reported in HPMS;
. *bysort state year : egen D_exp_I2=max(I2_t) if I2_t!=.;
.  *label var D_exp_I2 "Dummy=1 for state year if if at least one sample id reports maintenance";
.         *keep if _n<50;
. *Total lane miles IH in each state-year;
.  bysort state year : egen lane_miles_st=total(lane_miles);

. label var  lane_miles_st "Total IH lane miles in state year (HPMS-sample)" ;

. *Total lane miles resurfaced IH in each state-year;
.  gen lane_miles_x=I2_t*lane_miles;
(673 missing values generated)

. bysort state year : egen lane_milesI2_st=total(lane_miles_x);

. drop lane_miles_x;

. label var  lane_milesI2_st "Total I2 IH lane miles in state year (HPMS-sample)" ;

. *keep year state lane_miles lane_miles_st lane_milesI2_st I2_t;
. *order year state lane_miles lane_miles_st lane_milesI2_st I2_t;
. * Real IH Expenditure per IH lane mile;
. gen app_IH_plm=                 (app_IH_r/lane_miles_st );
(77,531 missing values generated)

. gen exp_IRI_IH_SF12a_plm=       (exp_IRI_IH_SF12a_r/lane_miles_st );
(673 missing values generated)

. gen exp_L_IH_SF12a_plm=         (exp_L_IH_SF12a_r/lane_miles_st );
(673 missing values generated)

. label var app_IH_plm            "Appropriations per lane mile" ;

. label var exp_IRI_IH_SF12a_plm  "Exp. Resurfacing per lane mile" ;

. label var exp_L_IH_SF12a_plm    "Exp. construction per lane mile" ;

. * Real IH Expenditure per resurfaced IH lane mile;
. gen app_IH_I2_plm=                      (app_IH_r/lane_milesI2_st );
(126,970 missing values generated)

. gen exp_IRI_IH_I2_SF12a_plm=            (exp_IRI_IH_SF12a_r/lane_milesI2_st );
(59,249 missing values generated)

. gen exp_L_IH_I2_SF12a_plm=              (exp_L_IH_SF12a_r/lane_milesI2_st );
(59,249 missing values generated)

. label var app_IH_I2_plm                 "Appropriations per resurf.lane m." ;

. label var exp_IRI_IH_I2_SF12a_plm       "Exp. Resurfacing per resurf. lane m." ;

. label var exp_L_IH_I2_SF12a_plm         "Exp. Construction per resurf.lane m." ;

. forvalues i=1(1)5{;
  2.                                 gen L`i'FHWA_apport_LW_r_plm=                   (L`i'FHWA_apport_LW_r/
> lane_milesI2_st );
  3. };
(59,279 missing values generated)
(59,279 missing values generated)
(59,279 missing values generated)
(59,279 missing values generated)
(59,279 missing values generated)

.         tab state year if Diri==.;

                     |                             Book year
     State fips code |      1980       1981       1982       1983       1984       1985 |     Total
---------------------+------------------------------------------------------------------+----------
             ALABAMA |         1          1          1          1          1          1 |       439 
             ARIZONA |         1          1          1          1          1          1 |     1,064 
            ARKANSAS |         1          1          1          1          1          1 |       641 
          CALIFORNIA |         1          1          1          1          1          1 |     1,437 
            COLORADO |         1          1          1          1          1          1 |       492 
         CONNECTICUT |         1          1          1          1          1          1 |     1,397 
            DELAWARE |         1          1          1          1          1          1 |       111 
DISTRICT OF COLUMBIA |         0          0          0          0          0          0 |        78 
             FLORIDA |         1          1          1          1          1          1 |     1,548 
             GEORGIA |         1          1          1          1          1          1 |     1,267 
               IDAHO |         1          1          1          1          1          1 |       492 
            ILLINOIS |         1          1          1          1          1          1 |       846 
             INDIANA |         1          1          1          1          1          1 |       683 
                IOWA |         1          1          1          1          1          1 |     2,175 
              KANSAS |         1          1          1          1          1          1 |       769 
            KENTUCKY |         1          1          1          1          1          1 |       767 
           LOUISIANA |         1          1          1          1          1          1 |     1,301 
               MAINE |         1          1          1          1          1          1 |     1,256 
            MARYLAND |         1          1          1          1          1          1 |       674 
       MASSACHUSETTS |         1          1          1          1          1          1 |     1,370 
            MICHIGAN |         1          1          1          1          1          1 |     1,280 
           MINNESOTA |         1          1          1          1          1          1 |       289 
         MISSISSIPPI |         1          1          1          1          1          1 |       497 
            MISSOURI |         1          1          1          1          1          1 |       537 
             MONTANA |         1          1          1          1          1          1 |       308 
            NEBRASKA |         1          1          1          1          1          1 |       243 
              NEVADA |         1          1          1          1          1          1 |       701 
       NEW HAMPSHIRE |         1          1          1          1          1          1 |       489 
          NEW JERSEY |         1          1          1          1          1          1 |       704 
          NEW MEXICO |         1          1          1          1          1          1 |       537 
            NEW YORK |         1          1          1          1          1          1 |       760 
      NORTH CAROLINA |         1          1          1          1          1          1 |       840 
        NORTH DAKOTA |         1          1          1          1          1          1 |       252 
                OHIO |         1          1          1          1          1          1 |     1,407 
            OKLAHOMA |         1          1          1          1          1          1 |     1,762 
              OREGON |         1          1          1          1          1          1 |       940 
        PENNSYLVANIA |         1          1          1          1          1          1 |     4,911 
        RHODE ISLAND |         1          1          1          1          1          1 |       278 
      SOUTH CAROLINA |         1          1          1          1          1          1 |       431 
        SOUTH DAKOTA |         1          1          1          1          1          1 |       528 
           TENNESSEE |         1          1          1          1          1          1 |     1,274 
               TEXAS |         1          1          1          1          1          1 |     1,487 
                UTAH |         1          1          1          1          1          1 |     1,019 
             VERMONT |         1          1          1          1          1          1 |       188 
            VIRGINIA |         1          1          1          1          1          1 |     1,073 
          WASHINGTON |         1          1          1          1          1          1 |       426 
       WEST VIRGINIA |         1          1          1          1          1          1 |     1,234 
           WISCONSIN |         1          1          1          1          1          1 |       930 
             WYOMING |         1          1          1          1          1          1 |       389 
---------------------+------------------------------------------------------------------+----------
               Total |        48         48         48         48         48         48 |    44,521 


                     |                             Book year
     State fips code |      1986       1987       1988       1989       1990       1991 |     Total
---------------------+------------------------------------------------------------------+----------
             ALABAMA |         1          1        145        145          1          2 |       439 
             ARIZONA |         1          1        174        177          0          1 |     1,064 
            ARKANSAS |         1          1        123        123         67         62 |       641 
          CALIFORNIA |         1          1        400        400          9         32 |     1,437 
            COLORADO |         1          1        246          7          6          1 |       492 
         CONNECTICUT |         1          1        226        230         19         18 |     1,397 
            DELAWARE |         1          1         23         25          1          0 |       111 
DISTRICT OF COLUMBIA |         0          0         15         15         15          0 |        78 
             FLORIDA |         1          1        276        279        280         22 |     1,548 
             GEORGIA |         1          1        283          8          1          3 |     1,267 
               IDAHO |         1          1        169        170          1          6 |       492 
            ILLINOIS |         1          1        306          0          3         61 |       846 
             INDIANA |         1          1        162        162        166          2 |       683 
                IOWA |         1          1        423        423        423        114 |     2,175 
              KANSAS |         1          1        186        189         58         55 |       769 
            KENTUCKY |         1          1        215        219          0          0 |       767 
           LOUISIANA |         1          1        184        203        203         44 |     1,301 
               MAINE |         1          1        168        168        168          2 |     1,256 
            MARYLAND |         1          1        196         45         49         65 |       674 
       MASSACHUSETTS |         1          1        427        427          5          1 |     1,370 
            MICHIGAN |         1          1        373        374         14         29 |     1,280 
           MINNESOTA |         1          1        148          1          0          4 |       289 
         MISSISSIPPI |         1          1        163        170          2          0 |       497 
            MISSOURI |         1          1        153        153          2          1 |       537 
             MONTANA |         1          1        196         16          0          0 |       308 
            NEBRASKA |         1          1         89         89          0          2 |       243 
              NEVADA |         1          1        151        152          0          0 |       701 
       NEW HAMPSHIRE |         1          1        118        118          0          0 |       489 
          NEW JERSEY |         1          1        169        181         40         34 |       704 
          NEW MEXICO |         1          1        262         27          4          0 |       537 
            NEW YORK |         1          1        315          2          0         20 |       760 
      NORTH CAROLINA |         1          1        158        159         46         21 |       840 
        NORTH DAKOTA |         1          1        110        110          1          1 |       252 
                OHIO |         1          1        401        397         77          0 |     1,407 
            OKLAHOMA |         1          1        247        425        216        220 |     1,762 
              OREGON |         1          1        202        202          0          1 |       940 
        PENNSYLVANIA |         1          1        749      1,532        287         84 |     4,911 
        RHODE ISLAND |         1          1         42         42         42          0 |       278 
      SOUTH CAROLINA |         1          1        141        141          2          0 |       431 
        SOUTH DAKOTA |         1          1        134        134          5          0 |       528 
           TENNESSEE |         1          1        252        252          0          0 |     1,274 
               TEXAS |         1          1        406          3          1          9 |     1,487 
                UTAH |         1          1        289        290          1          3 |     1,019 
             VERMONT |         1          1         90         56          0          0 |       188 
            VIRGINIA |         1          1        243        243          5          0 |     1,073 
          WASHINGTON |         1          1        199          2          1          0 |       426 
       WEST VIRGINIA |         1          1        383        400          0         20 |     1,234 
           WISCONSIN |         1          1        164        164        165          3 |       930 
             WYOMING |         1          1        121        123         49          9 |       389 
---------------------+------------------------------------------------------------------+----------
               Total |        48         48     10,815      9,373      2,435        952 |    44,521 


                     |                             Book year
     State fips code |      1992       1993       1994       1995       1996       1997 |     Total
---------------------+------------------------------------------------------------------+----------
             ALABAMA |        11         48          8          0          1          0 |       439 
             ARIZONA |         2         57          0          4        417          0 |     1,064 
            ARKANSAS |        26         29         42          5          2          5 |       641 
          CALIFORNIA |        21        239          7          4         12         19 |     1,437 
            COLORADO |        22         52          7         11          4          2 |       492 
         CONNECTICUT |        25        128          6        285        273         15 |     1,397 
            DELAWARE |         0         33          0          4          0          0 |       111 
DISTRICT OF COLUMBIA |         0         15          0          0          0          0 |        78 
             FLORIDA |         2        138         70         15         62         49 |     1,548 
             GEORGIA |        24        139        131         96         97         96 |     1,267 
               IDAHO |        10          0          0          0          0          2 |       492 
            ILLINOIS |        76        221         92         10          3          1 |       846 
             INDIANA |         9          2         60          5          2          4 |       683 
                IOWA |        39        392         23         55         46         22 |     2,175 
              KANSAS |        76        100          3          2          3          3 |       769 
            KENTUCKY |        10         84          5          1          1          0 |       767 
           LOUISIANA |        65        104         46         43         34         18 |     1,301 
               MAINE |         1         12         64          6          6          7 |     1,256 
            MARYLAND |        51        144          4         10          7          2 |       674 
       MASSACHUSETTS |         0        300         16          0          4         10 |     1,370 
            MICHIGAN |        48        156         86         80          1          0 |     1,280 
           MINNESOTA |         2         53          0          0          1          1 |       289 
         MISSISSIPPI |         5         35          0         10          5          4 |       497 
            MISSOURI |         9         62          3          0          0          0 |       537 
             MONTANA |         6         29          6          6          6          0 |       308 
            NEBRASKA |         4         22          8          0          0          0 |       243 
              NEVADA |        11        158        156         18         13          1 |       701 
       NEW HAMPSHIRE |         3          3          0          0          0          0 |       489 
          NEW JERSEY |         9          8        135          6          4          6 |       704 
          NEW MEXICO |         8          1         47          2          0          1 |       537 
            NEW YORK |        13        235          4          6          4          4 |       760 
      NORTH CAROLINA |        51        103         10         21          7          4 |       840 
        NORTH DAKOTA |         1          1          0          0          0          9 |       252 
                OHIO |         7        242         39          2          4          0 |     1,407 
            OKLAHOMA |         9        441          0         20          0          0 |     1,762 
              OREGON |         2         54          1          0          0          0 |       940 
        PENNSYLVANIA |       163        666          0         28        119         65 |     4,911 
        RHODE ISLAND |         3         36          0          0          0         46 |       278 
      SOUTH CAROLINA |         2         55         21          4          0          0 |       431 
        SOUTH DAKOTA |         0        117          3          5          2         16 |       528 
           TENNESSEE |       253        253          3          5         21         25 |     1,274 
               TEXAS |         2         27        129        151        135         15 |     1,487 
                UTAH |        28         94          2          1          3          0 |     1,019 
             VERMONT |         2          0          0          0          0          0 |       188 
            VIRGINIA |         1        135         25          0          0          0 |     1,073 
          WASHINGTON |        47         52          0          0          0          0 |       426 
       WEST VIRGINIA |         0         13          0          5          0          0 |     1,234 
           WISCONSIN |        11         45          5          3         19          0 |       930 
             WYOMING |        18          2         27          0          0          0 |       389 
---------------------+------------------------------------------------------------------+----------
               Total |     1,188      5,335      1,294        929      1,318        452 |    44,521 


                     |                             Book year
     State fips code |      1998       1999       2000       2001       2002       2003 |     Total
---------------------+------------------------------------------------------------------+----------
             ALABAMA |         0         22          3          0          2          0 |       439 
             ARIZONA |         0          0          0         29          1         66 |     1,064 
            ARKANSAS |         5         14         69          2          1          0 |       641 
          CALIFORNIA |        89          9         17          0          9          8 |     1,437 
            COLORADO |         3         13         10          3          1         27 |       492 
         CONNECTICUT |         2         45         18          2         76          7 |     1,397 
            DELAWARE |         0          0          0          0          1          1 |       111 
DISTRICT OF COLUMBIA |         0         15          1          1          1          0 |        78 
             FLORIDA |        32         70         33         28         51         11 |     1,548 
             GEORGIA |        73         53         25          6          0         11 |     1,267 
               IDAHO |         1         61         21          0          0         14 |       492 
            ILLINOIS |         0         23          0          2          5          1 |       846 
             INDIANA |         2         55          0          0          2          0 |       683 
                IOWA |        20         59         19          3         16         29 |     2,175 
              KANSAS |         7         21         20          5          5          2 |       769 
            KENTUCKY |         0         16          7        127          1         31 |       767 
           LOUISIANA |         6        118          3          2         23         20 |     1,301 
               MAINE |        33        115         52          0          4         10 |     1,256 
            MARYLAND |         3         14          3          3         13         35 |       674 
       MASSACHUSETTS |        16          7          5          0         31         57 |     1,370 
            MICHIGAN |         0         14          1         11          0         43 |     1,280 
           MINNESOTA |         0         19          0          0          1          3 |       289 
         MISSISSIPPI |         4         14          0          4          5         27 |       497 
            MISSOURI |         1          8          0          6          0          5 |       537 
             MONTANA |         0          8          0          0          0         16 |       308 
            NEBRASKA |         0          1          9          0          0          2 |       243 
              NEVADA |         0          2          0          0          0          0 |       701 
       NEW HAMPSHIRE |         0         24         79         32          0         51 |       489 
          NEW JERSEY |         5          9         12          3          1         46 |       704 
          NEW MEXICO |         1         90          7          0         14         12 |       537 
            NEW YORK |         0         30          0          0          8          0 |       760 
      NORTH CAROLINA |        11         51         14          3         30         30 |       840 
        NORTH DAKOTA |         0          0          0          0          0          2 |       252 
                OHIO |         1         86          1          4          1         60 |     1,407 
            OKLAHOMA |         0         59          3          9         10         60 |     1,762 
              OREGON |         0        308         27         27          0          3 |       940 
        PENNSYLVANIA |         3         31         21         88        471        264 |     4,911 
        RHODE ISLAND |        46          1          3          3          0          0 |       278 
      SOUTH CAROLINA |         0          7          0          0          0          8 |       431 
        SOUTH DAKOTA |        24         35          5          1          4          4 |       528 
           TENNESSEE |        26         25         10          3         30         69 |     1,274 
               TEXAS |         3        162          6          5         60        160 |     1,487 
                UTAH |         3        133         65         11         11         16 |     1,019 
             VERMONT |         0          8          0          0          1          0 |       188 
            VIRGINIA |         1        325          4          6         17         10 |     1,073 
          WASHINGTON |         0         33          0          0          0          5 |       426 
       WEST VIRGINIA |         1         15         85          0          7          0 |     1,234 
           WISCONSIN |         6         14        208          0          1         57 |       930 
             WYOMING |        23          0          0          0          0          0 |       389 
---------------------+------------------------------------------------------------------+----------
               Total |       451      2,242        866        429        915      1,283 |    44,521 


                     |                             Book year
     State fips code |      2004       2005       2006       2007       2008       2009 |     Total
---------------------+------------------------------------------------------------------+----------
             ALABAMA |         6         10          1          9         11          1 |       439 
             ARIZONA |        71          1          1          0         49          1 |     1,064 
            ARKANSAS |        10         23         16          3          0          1 |       641 
          CALIFORNIA |        18         43         69          7         11          1 |     1,437 
            COLORADO |         3         34         21          0          5          1 |       492 
         CONNECTICUT |         3          1          3          1          0          1 |     1,397 
            DELAWARE |         0          2          7          0          0          1 |       111 
DISTRICT OF COLUMBIA |         0          0          0          0          0          0 |        78 
             FLORIDA |        49         40          6          6         15          1 |     1,548 
             GEORGIA |        69          9         14         60         55          1 |     1,267 
               IDAHO |         2         19          1          1          0          1 |       492 
            ILLINOIS |        12          6          9          1          0          1 |       846 
             INDIANA |         1          0          0         33          2          1 |       683 
                IOWA |        13         11          6          8         17          1 |     2,175 
              KANSAS |        14          5          0          1          0          1 |       769 
            KENTUCKY |        12          0          3          7         14          1 |       767 
           LOUISIANA |        42         44         20         32         33          1 |     1,301 
               MAINE |       302         42         74          8          0          1 |     1,256 
            MARYLAND |        15          1          0          0          0          1 |       674 
       MASSACHUSETTS |        15         12          7          8          8          1 |     1,370 
            MICHIGAN |        10         13         11          2          0          1 |     1,280 
           MINNESOTA |        28          0          0          8          6          1 |       289 
         MISSISSIPPI |         6          5         15          3          6          1 |       497 
            MISSOURI |        63          4          1         50          2          1 |       537 
             MONTANA |         2          2          1          0          0          1 |       308 
            NEBRASKA |         2          0          1          0          0          1 |       243 
              NEVADA |        21          2          0          0          2          1 |       701 
       NEW HAMPSHIRE |        27          1          2          3         14          1 |       489 
          NEW JERSEY |         2          5          5          3          7          1 |       704 
          NEW MEXICO |        15          0          0          0         32          1 |       537 
            NEW YORK |         0          0         82          9         14          1 |       760 
      NORTH CAROLINA |         4         95          0          4          4          1 |       840 
        NORTH DAKOTA |         2          0          1          0          0          1 |       252 
                OHIO |        45         24          2          0          0          1 |     1,407 
            OKLAHOMA |         0         13         13          3          0          1 |     1,762 
              OREGON |        82          4          6          4          3          1 |       940 
        PENNSYLVANIA |       135         25         12         65         89          1 |     4,911 
        RHODE ISLAND |         0          0          0          0          0          1 |       278 
      SOUTH CAROLINA |         3         23          0          8          2          1 |       431 
        SOUTH DAKOTA |        15          0          0         10          0          1 |       528 
           TENNESSEE |        32          0          0          1          0          1 |     1,274 
               TEXAS |        21         39         43         12         84          1 |     1,487 
                UTAH |        27          1          7          2         18          1 |     1,019 
             VERMONT |         0         17          0          0          0          1 |       188 
            VIRGINIA |        25         15          0          2          2          1 |     1,073 
          WASHINGTON |        31          0          0         24         18          1 |       426 
       WEST VIRGINIA |         0         56        182         18         35          1 |     1,234 
           WISCONSIN |        44          2          2          0          3          1 |       930 
             WYOMING |         0          0          2          1          0          1 |       389 
---------------------+------------------------------------------------------------------+----------
               Total |     1,299        649        646        417        561         48 |    44,521 


                     |                       Book year
     State fips code |      2010       2011       2012       2013       2014 |     Total
---------------------+-------------------------------------------------------+----------
             ALABAMA |         1          1          1          1          1 |       439 
             ARIZONA |         1          1          1          1          1 |     1,064 
            ARKANSAS |         1          1          1          1          1 |       641 
          CALIFORNIA |         1          1          1          1          1 |     1,437 
            COLORADO |         1          1          1          1          1 |       492 
         CONNECTICUT |         1          1          1          1          1 |     1,397 
            DELAWARE |         1          1          1          1          1 |       111 
DISTRICT OF COLUMBIA |         0          0          0          0          0 |        78 
             FLORIDA |         1          1          1          1          1 |     1,548 
             GEORGIA |         1          1          1          1          1 |     1,267 
               IDAHO |         1          1          1          1          1 |       492 
            ILLINOIS |         1          1          1          1          1 |       846 
             INDIANA |         1          1          1          1          1 |       683 
                IOWA |         1          1          1          1          1 |     2,175 
              KANSAS |         1          1          1          1          1 |       769 
            KENTUCKY |         1          1          1          1          1 |       767 
           LOUISIANA |         1          1          1          1          1 |     1,301 
               MAINE |         1          1          1          1          1 |     1,256 
            MARYLAND |         1          1          1          1          1 |       674 
       MASSACHUSETTS |         1          1          1          1          1 |     1,370 
            MICHIGAN |         1          1          1          1          1 |     1,280 
           MINNESOTA |         1          1          1          1          1 |       289 
         MISSISSIPPI |         1          1          1          1          1 |       497 
            MISSOURI |         1          1          1          1          1 |       537 
             MONTANA |         1          1          1          1          1 |       308 
            NEBRASKA |         1          1          1          1          1 |       243 
              NEVADA |         1          1          1          1          1 |       701 
       NEW HAMPSHIRE |         1          1          1          1          1 |       489 
          NEW JERSEY |         1          1          1          1          1 |       704 
          NEW MEXICO |         1          1          1          1          1 |       537 
            NEW YORK |         1          1          1          1          1 |       760 
      NORTH CAROLINA |         1          1          1          1          1 |       840 
        NORTH DAKOTA |         1          1          1          1          1 |       252 
                OHIO |         1          1          1          1          1 |     1,407 
            OKLAHOMA |         1          1          1          1          1 |     1,762 
              OREGON |         1          1          1          1          1 |       940 
        PENNSYLVANIA |         1          1          1          1          1 |     4,911 
        RHODE ISLAND |         1          1          1          1          1 |       278 
      SOUTH CAROLINA |         1          1          1          1          1 |       431 
        SOUTH DAKOTA |         1          1          1          1          1 |       528 
           TENNESSEE |         1          1          1          1          1 |     1,274 
               TEXAS |         1          1          1          1          1 |     1,487 
                UTAH |         1          1          1          1          1 |     1,019 
             VERMONT |         1          1          1          1          1 |       188 
            VIRGINIA |         1          1          1          1          1 |     1,073 
          WASHINGTON |         1          1          1          1          1 |       426 
       WEST VIRGINIA |         1          1          1          1          1 |     1,234 
           WISCONSIN |         1          1          1          1          1 |       930 
             WYOMING |         1          1          1          1          1 |       389 
---------------------+-------------------------------------------------------+----------
               Total |        48         48         48         48         48 |    44,521 

. *drop state-years with no resurfacing expenditure;
. drop if exp_IRI_IH_SF12a_r==0;
(5,758 observations deleted)

. drop if exp_IRI_IH_SF12a_r==.;
(0 observations deleted)

. *drop id-years with bad IRI data;
. drop if Diri==.;
(41,806 observations deleted)

. drop if abs(Diri)>200;
(344 observations deleted)

. *drop state-years with no resurfacing;
. drop if lane_milesI2_st==.|lane_milesI2_st==0;
(50,587 observations deleted)

. *drop DC and years outside sample;
. drop if state==11;
(0 observations deleted)

. drop if year<1992;
(23,548 observations deleted)

. drop if year>2008;
(0 observations deleted)

. tab state;

     State fips code |      Freq.     Percent        Cum.
---------------------+-----------------------------------
             ALABAMA |      1,169        0.63        0.63
             ARIZONA |      8,057        4.33        4.96
            ARKANSAS |      1,877        1.01        5.97
          CALIFORNIA |      6,247        3.36        9.33
            COLORADO |      2,132        1.15       10.47
         CONNECTICUT |      3,652        1.96       12.43
            DELAWARE |        171        0.09       12.53
             FLORIDA |      4,462        2.40       14.92
             GEORGIA |      3,607        1.94       16.86
               IDAHO |      2,799        1.50       18.37
            ILLINOIS |      3,718        2.00       20.37
                IOWA |      3,932        2.11       22.48
              KANSAS |      1,762        0.95       23.43
            KENTUCKY |      2,749        1.48       24.90
           LOUISIANA |      2,098        1.13       26.03
               MAINE |      2,057        1.11       27.14
            MARYLAND |      4,420        2.38       29.51
       MASSACHUSETTS |      2,135        1.15       30.66
            MICHIGAN |      4,737        2.55       33.21
           MINNESOTA |      2,251        1.21       34.42
         MISSISSIPPI |      1,197        0.64       35.06
            MISSOURI |      1,555        0.84       35.89
             MONTANA |      2,911        1.56       37.46
            NEBRASKA |      1,643        0.88       38.34
              NEVADA |      1,363        0.73       39.08
       NEW HAMPSHIRE |      1,884        1.01       40.09
          NEW JERSEY |      2,593        1.39       41.48
          NEW MEXICO |      2,201        1.18       42.66
            NEW YORK |      5,272        2.83       45.50
      NORTH CAROLINA |      4,507        2.42       47.92
        NORTH DAKOTA |      1,623        0.87       48.79
                OHIO |      7,468        4.01       52.81
            OKLAHOMA |      2,488        1.34       54.14
              OREGON |      5,303        2.85       56.99
        PENNSYLVANIA |     47,182       25.36       82.35
        RHODE ISLAND |        325        0.17       82.53
      SOUTH CAROLINA |      1,111        0.60       83.12
        SOUTH DAKOTA |      2,865        1.54       84.66
           TENNESSEE |      2,181        1.17       85.84
               TEXAS |      7,085        3.81       89.64
                UTAH |      2,588        1.39       91.04
             VERMONT |      1,326        0.71       91.75
            VIRGINIA |      2,191        1.18       92.93
          WASHINGTON |      2,366        1.27       94.20
       WEST VIRGINIA |      6,434        3.46       97.66
           WISCONSIN |      2,491        1.34       98.99
             WYOMING |      1,870        1.01      100.00
---------------------+-----------------------------------
               Total |    186,055      100.00

. *aadt variables;
.         gen aadt2_10000=aadt_1000^2;

. label var aadt2_10000 "(`:  var label aadt_1000')^2" ;

. gen aadt3_10000=aadt_1000^3;

. label var aadt3_10000 "(`:  var label aadt_1000')^3" ;

.         *Set up state year and I2 x year FE;
. *calculate number of years that each state is present in data;
. preserve;

.         sort state year;

.         by state year: gen counter1=_n;

.         keep if counter1==1;
(185,480 observations deleted)

.         display "count number of stateXyears for reference";
count number of stateXyears for reference

.         sum year;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        year |        575     1999.61    4.837559       1992       2008

.         sort state;

.         by state: gen num_years=_N;

.         by state: gen counter3=_n;

.         keep if counter3==1;
(528 observations deleted)

.         label var num_years "Years state present in data";

.         keep state num_years;

.         tab num_years;

Years state |
 present in |
       data |      Freq.     Percent        Cum.
------------+-----------------------------------
          5 |          2        4.26        4.26
          6 |          1        2.13        6.38
          7 |          2        4.26       10.64
          8 |          3        6.38       17.02
          9 |          5       10.64       27.66
         10 |          6       12.77       40.43
         12 |          2        4.26       44.68
         13 |          2        4.26       48.94
         14 |         10       21.28       70.21
         15 |          5       10.64       80.85
         16 |          2        4.26       85.11
         17 |          7       14.89      100.00
------------+-----------------------------------
      Total |         47      100.00

.         display "states present 1990-2008 --- use Texas 1990 for omitted state-year";
states present 1990-2008 --- use Texas 1990 for omitted state-year

.         tab state if num_years==18;
no observations

.         tab state if num_years==18, nol;
no observations

. // Texas, fips 48 is present in all years
>         sort state;

.         save stateyears,replace;
(file stateyears.dta not found)
file stateyears.dta saved

. restore;

. merge m:1 state using stateyears;
(label fips already defined)

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                           186,055  (_merge==3)
    -----------------------------------------

. tab _merge;

   Matching result from |
                  merge |      Freq.     Percent        Cum.
------------------------+-----------------------------------
            Matched (3) |    186,055      100.00      100.00
------------------------+-----------------------------------
                  Total |    186,055      100.00

. order state state_name year num_years;

. erase stateyears.dta;

. *make state-year indicators for state years present in data;
.         levelsof year, local(year_list);
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008

. levelsof state, local(state_list);
1 4 5 6 8 9 10 12 13 16 17 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 45 46
>  47 48 49 50 51 53 54 55 56

. display "`state_list'";
1 4 5 6 8 9 10 12 13 16 17 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 45 46
>  47 48 49 50 51 53 54 55 56

. display "`year_list'";
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008

. local i_stateyear=1;

. foreach k_year of local year_list{;
  2.         foreach k_state of local state_list{;
  3.                 if !("`k_year'"=="1990"&"`k_state'"=="48"){;
  4.  //texas 1990 omitted
>                         *make dummy for state-year;
.                         gen stateXyearI_`k_year'_`k_state'=cond(year==`k_year'&state==`k_state',1,0);
  5.                         *drop indicator if state-year missing from data;
.                         quiet sum stateXyearI_`k_year'_`k_state';
  6.                         local tester =r(mean) ;
  7.                         if `tester'==0{;
  8.                                 drop stateXyearI_`k_year'_`k_state';
  9.                                 };
 10.                         *increment counter if state-year present in data. counter is just used as a di
> agnostic;
.                         if `tester'>0{;
 11.                                 local ++i_stateyear;
 12.                                 };
 13.                         };
 14. //end skip texas 1990 if
>                 };
 15. //end state loop
>         };

. //end year loop
> display "`i_stateyear'-1 state-year indicators created -- should match tab above";
576-1 state-year indicators created -- should match tab above

. *make year X I2_t indicators and year X I2_t * expenditure per mile variables;
.         levelsof year, local(year_list);
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008

. display "`year_list'";
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008

. foreach k_year of local year_list{;
  2.         gen I2_t_x`k_year'                      =cond(year==`k_year'& I2_t==1,1,0);
  3.         gen I2_t_`k_year'_exp_I2        =I2_t_x`k_year'*exp_IRI_IH_SF12a_plm;
  4.         gen I2_t_`k_year'_exp_L         =I2_t_x`k_year'*exp_L_IH_I2_SF12a_plm;
  5.                         label var I2_t_`k_year'_exp_I2          "IRI exp per I2 lane mile `k_year'";
  6.         label var I2_t_`k_year'_exp_L           "L exp per I2 lane mile `k_year'";
  7.         };

. //end year loop
> 
>         
>         
> gen urban=1 if  D_urban==1 | D_small_urban==1;
(91,747 missing values generated)

. replace urban =0 if D_rural==1 ;
(91,747 real changes made)

. label var urban "Dummy=1 if urban" ;

.                                         * time, for estimating trends;
. gen time =year-1990;

. gen time2 =time^2;

. gen time3 =time^3;

. label var time2 "\(time^2\)" ;

. label var time3 "\(time^3\)" ;

. *TIME TREND DUMMIES;
. gen     periods=1 if  year>=1984&year<=1989;
(186,055 missing values generated)

. replace periods=2 if  year>=1990&year<=1994;
(28,365 real changes made)

. replace periods=3 if  year>=1995&year<=1999;
(55,231 real changes made)

. replace periods=4 if  year>=2000&year<=2004;
(58,770 real changes made)

. replace periods=5 if  year>=2005&year<=2008;
(43,689 real changes made)

. tab year periods, m ;

           |                   periods
 Book year |         2          3          4          5 |     Total
-----------+--------------------------------------------+----------
      1992 |    10,524          0          0          0 |    10,524 
      1993 |     6,932          0          0          0 |     6,932 
      1994 |    10,909          0          0          0 |    10,909 
      1995 |         0     10,735          0          0 |    10,735 
      1996 |         0     11,646          0          0 |    11,646 
      1997 |         0     11,080          0          0 |    11,080 
      1998 |         0     11,326          0          0 |    11,326 
      1999 |         0     10,444          0          0 |    10,444 
      2000 |         0          0     11,846          0 |    11,846 
      2001 |         0          0     12,857          0 |    12,857 
      2002 |         0          0     10,956          0 |    10,956 
      2003 |         0          0     11,547          0 |    11,547 
      2004 |         0          0     11,564          0 |    11,564 
      2005 |         0          0          0     10,878 |    10,878 
      2006 |         0          0          0     10,944 |    10,944 
      2007 |         0          0          0     10,840 |    10,840 
      2008 |         0          0          0     11,027 |    11,027 
-----------+--------------------------------------------+----------
     Total |    28,365     55,231     58,770     43,689 |   186,055 

. label define periods 1 "1984-1989"
>                                         2 "1990-1994"
>                                         3 "1995-1999"
>                                         4 "2000-2004"
>                                         5 "2005-2008";

. label values periods periods;

. *** Gen state_year to cluster standar errors ;
. egen state_year= group(state year);

. *make I2_t * expenditure per mile variables;
.         foreach I in Ids_t Iall_t I2_t{;
  2.         gen `I'_exp_I2          =`I'*exp_IRI_IH_SF12a_plm;
  3.         gen `I'_exp_L           =`I'*exp_L_IH_I2_SF12a_plm;
  4.         gen `I'_app_I2                  =`I'*app_IH_I2_plm ;
  5.                 forvalues i=1(1)5{;
  6.                 gen `I'_L`i'_apport_I2=`I'*L`i'FHWA_apport_LW_r_plm;
  7.         };
  8.                         *LABEL FOR TEX OUPTU;
.         label var `I'_exp_I2            "\( \mathds{1}_{ist}(q)\imath^q_{st}\)";
  9. };
(17,456 missing values generated)
(17,456 missing values generated)
(17,456 missing values generated)

.         # d cr ;
delimiter now cr
.         
. 
end of do-file

. ** generate a variable of average number of years between maintenance in a segment;
. bysort id (year): egen N_maint=total(I2_t);

. bysort id (year): egen xx=count(year);

. gen av_year_maint=xx/(N_maint+1);

. label var av_year_maint "mean t for I in seg. i";

. tab av_year_maint;

 mean t for |
I in seg. i |      Freq.     Percent        Cum.
------------+-----------------------------------
         .5 |        239        0.13        0.13
   .6666667 |          4        0.00        0.13
        .75 |          3        0.00        0.13
          1 |      4,845        2.60        2.74
       1.25 |         15        0.01        2.74
   1.333333 |         36        0.02        2.76
        1.5 |        468        0.25        3.02
   1.666667 |         50        0.03        3.04
       1.75 |         42        0.02        3.06
          2 |      4,274        2.30        5.36
   2.166667 |         13        0.01        5.37
       2.25 |         36        0.02        5.39
   2.333333 |        154        0.08        5.47
        2.5 |      1,335        0.72        6.19
   2.666667 |        400        0.21        6.40
       2.75 |         22        0.01        6.42
        2.8 |         14        0.01        6.42
          3 |      5,379        2.89        9.31
       3.25 |        156        0.08        9.40
   3.333333 |        670        0.36        9.76
        3.4 |         51        0.03        9.79
        3.5 |      2,016        1.08       10.87
   3.666667 |        209        0.11       10.98
       3.75 |        210        0.11       11.09
          4 |     10,652        5.73       16.82
       4.25 |        612        0.33       17.15
   4.333333 |      1,157        0.62       17.77
        4.5 |      3,483        1.87       19.64
   4.666667 |      1,652        0.89       20.53
          5 |     10,405        5.59       26.12
   5.333333 |        384        0.21       26.33
        5.5 |      2,695        1.45       27.78
   5.666667 |      5,100        2.74       30.52
          6 |     12,486        6.71       37.23
        6.5 |      4,706        2.53       39.76
          7 |     11,816        6.35       46.11
        7.5 |      8,670        4.66       50.77
          8 |     10,552        5.67       56.44
        8.5 |     14,331        7.70       64.14
          9 |      8,478        4.56       68.70
         10 |      5,440        2.92       71.62
         11 |      4,818        2.59       74.21
         12 |      9,228        4.96       79.17
         13 |      5,408        2.91       82.08
         14 |      7,000        3.76       85.84
         15 |     10,350        5.56       91.41
         16 |      2,000        1.07       92.48
         17 |     13,991        7.52      100.00
------------+-----------------------------------
      Total |    186,055      100.00

. drop  xx;

. *------------------------------------------------;
.  *regressions;
.  *-----------------------------------------------;
. *inches per mile;
. tab year;

  Book year |      Freq.     Percent        Cum.
------------+-----------------------------------
       1992 |     10,524        5.66        5.66
       1993 |      6,932        3.73        9.38
       1994 |     10,909        5.86       15.25
       1995 |     10,735        5.77       21.02
       1996 |     11,646        6.26       27.27
       1997 |     11,080        5.96       33.23
       1998 |     11,326        6.09       39.32
       1999 |     10,444        5.61       44.93
       2000 |     11,846        6.37       51.30
       2001 |     12,857        6.91       58.21
       2002 |     10,956        5.89       64.10
       2003 |     11,547        6.21       70.30
       2004 |     11,564        6.22       76.52
       2005 |     10,878        5.85       82.36
       2006 |     10,944        5.88       88.25
       2007 |     10,840        5.83       94.07
       2008 |     11,027        5.93      100.00
------------+-----------------------------------
      Total |    186,055      100.00

. local listcontinous "c.time cont Baseline" ;

. local listcontinous2 "c.time_+_c.time2 cont_2" ;

. local listdiscrete  "ib2.periods dum Periods" ;

. gen no_trucks_aadt=aadt_10000 - trucks_av_10000;

. label var no_trucks_aadt "No trucks AADT/10000";

. label var trucks_av_10000 "Trucks AADT/10000";

. gen I2_t_D_rig=I2_t*D_rig ;
(167 missing values generated)

. local keep_rule_all "if 1==1 ";

. local keep_rule_after1992 "if year>1992" ;

.         local time              = word("`listcontinous'",1) ;

.         local time `:subinstr local time `"_+_"' `" "', ';

.         local name              = word("`listcontinous'",2);

.         local title         = word("`listcontinous'",3);

.                 gen I2_t_exp_I2Xtime=I2_t_exp_I2*time;

.         gen I2_t_app_I2Xtime=I2_t_app_I*time;
(17,456 missing values generated)

.         label var I2_t_exp_I2Xtime "$ \mathds{1}_{ist}(q)\imath^q_{st}\times t$";

.         label var  time  "$ t $";

.         label var I2_t_D_rig "$\mathds{1}_{ist}(q) \times rigid $";

.                                 local aadt              = word("`list`a''",1) ;

.                 local aadt `:subinstr local aadt `"_+_"' `" "', all ';

.                 local aadt_name          = word("`list`a''",2);

.         macro dir;
prehead_end_bigskip:
                \begin{tabular}{l*{@span}{c}}\hline\hline \bigskip\\[6ex])
prehead_end:    \begin{tabular}{l*{@span}{c}}\hline\hline)
T_gm_fix_span:  0
rev_var:        rev_grand_total_mt_r rev_total_h_r rev_total_mt_r rev_total_m_fuel_h_r
S_ADO:          `"BASE"';`"SITE"';`"."';`"PERSONAL"';`"PLUS"';`"OLDPLACE"';`"scheme"'
output:         ../
ReS_Call:       version 17:
var_counterfactual:
                RHS_mtn_92_08_r_high RHS_mtn_92_08_r92 RHS_mtn_92_08_p_q92 RHS_mtn_92_08_p_L92
                RHS_mtn_92_08_VMT92
var_euler:      RHS_mtn_lowess RHS_mtn_beta RHS_mtn_92_08 RHS_mtn_IV_92_08 RHS_mtn_IV_all
var_euler_cond: r_h_q_alpha1_lowess r_h_q_alpha1_beta r_h_q_alpha1_92_08 r_h_q_alpha1_IV_92_08
                r_h_q_alpha1_IV_all r_h_q_alpha4_lowess r_h_q_alpha4_beta r_h_q_alpha4_92_08
                r_h_q_alpha4_IV_92_08 r_h_q_alpha4_IV_all r_h_L_alpha1_lowess r_h_L_alpha1_beta
                r_h_L_alpha1_92_08 r_h_L_alpha1_IV_92_08 r_h_L_alpha1_IV_all r_h_L_alpha4_lowess
                r_h_L_alpha4_beta r_h_L_alpha4_92_08 r_h_L_alpha4_IV_92_08 r_h_L_alpha4_IV_all
alpha:          .4
kappa:          1.60000000000e-06
delta10:        .1
delta:          .1
more_var:       Dcat_surface_cat surface_cat surface_type average_grade_seg pavement_section truck_route
                sh_h20_10m_s sh_urb_10m_s sh_elev_10m_s sh_sd_elev_10m_s sh_temp_10m_s sh_precip_10m_s
                multiple_id_1998_before
var_outcomes:   iri sn_d urban aadt_10000 pavement_thickness
SE_note:        Standard Errors in Parentheses Clustered at the State Level
appendix_var:   average_grade_seg sh_elev_10m_s sh_h20_10m_s
main_var:       aadt_10000 urban sh_urb_10m_s D_rig sn_d union_Mem_Total
prehead_start:  prehead(\begin{table}[H]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
                \caption{@title} \setlength{\tabcolsep}{1pt}
postfoot:       postfoot(\hline\hline \multicolumn{@span}{l}{\footnotesize Standard Errors in Parentheses
                Clustered at the State-Year Level. }\\ \multicolumn{@span}{l}{\footnotesize @starlegend. }
                \end{tabular}\end{table})
prehead_start_longcol:
                prehead(\begin{table}[!htb]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
                \caption{@title} \setlength{\tabcolsep}{6pt}
exp_var:        exp_L_IH_SF12a_r exp_IRI_IH_SF12a_r exp_IH_mtn_SF12a_r exp_IH_mtn_SF12_r exp_row_IH_all
                exp_relocation_IH_all_r s_vmt_IH u_vmt_IH s_vmt_trucks_av_IH s_vmt_trucks_peak_IH
                u_inches_IH s_inches_IH u_inches_rural u_inches_urban s_vmt_NHS u_vmt_rural u_vmt_urban
comp_var:       lm_IH_h2O lm_IH_urb lm_IH_elev lm_IH_temp lm_IH_precip lm_IH_sd_elev lm_IH_grade lm_IH_new
                Dmiles sh_h20_10m_s sh_urb_10m_s sh_elev_10m_s sh_temp_10m_s sh_precip_10m_s
                sh_sd_elev_10m_s lm_IH_unionization lm_IHunionization_Mem_Priv_Cons
                lm_IHunionization_Mem_Total
lm_var:         u_lane_miles_IH u_lane_miles_rural u_lane_miles_urban u_miles_IH s_lane_miles_IH
                s_lane_miles_rural_IH s_lane_miles_urban_IH s_lane_miles_rig_IH
new_var_dummy:  new_program01_grad
controls_a:     i.year i.sy_grado i.iddepartamento_cotiz edad edad2 male_fixed
controls_2:     a e
controls:       0 a b c d e
new_var:        i.new_cat01_grad_ac new_program01_grad
reg_all:        reg
variables:      ln_w
r_dep_back_psm: Family Inc. and Parents Edu.=*fami_ing_fmliar_mensual *max_educa_SB11 background
r_dep_lab_psm:   Employment Region= *iddepartamento_cotiz region" "Year and Graduation Date FE=*sy_grado
                *year y
r_dep_back:     Family Inc. and Parents Edu.=*fami_ing_fmliar_mensual *max_educa_SB11
r_dep_lab:       Employment Region= *iddepartamento_cotiz" "Year and Graduation Date FE=*sy_grado *year
dep_lab:        i.year i.sy_grado i.iddepartamento_cotiz
background:     i.fami_ing_fmliar_mensual i.max_educa_SB11
area:           i.idarea
saber11_c:      p_biologia p_matematica p_filosofia p_fisica p_quimica p_lenguaje p_ciencias_sociales
ind:            edad edad2 male_fixed
edu_char:       i.idnucleo i.idmodalidad
educ_level:     i.idmodalidad
type_educ:      i.idmodalidad
area_educ:      i.idnucleo
geo:            i.iddepartamento_ies
IES_char:       i.caracteries d_publica
reg_formal:     reg
options_psm:    se br ar2 label nogaps modelwidth(7) drop() compress star(* 0.10 ** 0.05 *** 0.001)
                indicate( " Employment Region= *iddepartamento_cotiz region" "Year and Graduation Date
                FE=*sy_grado *year y" "Demographics=edad edad2 male_fixed" "Deciles in ST Saber 11= p_cat
                *p_lenguaje_cat *p_quimica_cat *p_fisica_cat *p_filosofia_cat *p_filosofia_cat
                *p_matematica_cat *p_ciencias_sociales_cat *p_biologia_cat" "Family Inc. and Parents
                Edu.=*fami_ing_fmliar_mensual *max_educa_SB11 background" "High school
                FE=cole_codigo_colegio" "Area of Study= *idnucleo idnucleo" "Duration of
                Program=*idmodalidad idmodalidad" "Institution Characteristics=*caracteries d_publica" "HE
                Inst. Region FE= *iddepartamento_ies iddepartamento_ies" )
options:        se br ar2 label nogaps modelwidth(7) drop() star(* 0.10 ** 0.05 *** 0.001) compress
                indicate( " Employment Region= *iddepartamento_cotiz" "Year and Graduation Date
                FE=*sy_grado *year" "Demographics=edad edad2 male_fixed" "Deciles in ST Saber
                11=*p_lenguaje_cat *p_quimica_cat *p_fisica_cat *p_filosofia_cat *p_filosofia_cat
                *p_matematica_cat *p_ciencias_sociales_cat *p_biologia_cat" "Family Inc. and Parents
                Edu.=*fami_ing_fmliar_mensual *max_educa_SB11" "High school FE=cole_codigo_colegio" "Area
                of Study= *idnucleo" "Duration of Program=*idmodalidad" "Institution
                Characteristics=*caracteries d_publica" "HE Inst. Region FE= *iddepartamento_ies " )
controls_inst:  i.year i.sy_grado i.iddepartamento_cotiz edad edad2 male_fixed i.p_biologia_cat
                i.p_matematica_cat i.p_filosofia_cat i.p_fisica_cat i.p_quimica_cat i.p_lenguaje_cat
                i.p_ciencias_sociales_cat i.fami_ing_fmliar_mensual i.max_educa_SB11 i.idmodalidad
                i.iddepartamento_ies
controls_e_c2:  i.year i.sy_grado i.iddepartamento_cotiz edad edad2 male_fixed p_biologia p_matematica
                p_filosofia p_fisica p_quimica p_lenguaje p_ciencias_sociales p_biologia2 p_matematica2
                p_filosofia2 p_fisica2 p_quimica2 p_lenguaje2 p_ciencias_sociales2
                i.fami_ing_fmliar_mensual i.max_educa_SB11 i.idnucleo i.idmodalidad i.caracteries d_publica
                i.iddepartamento_ies
controls_e_c:   i.year i.sy_grado i.iddepartamento_cotiz edad edad2 male_fixed p_biologia p_matematica
                p_filosofia p_fisica p_quimica p_lenguaje p_ciencias_sociales i.fami_ing_fmliar_mensual
                i.max_educa_SB11 i.idnucleo i.idmodalidad i.caracteries d_publica i.iddepartamento_ies
controls_e:     i.year i.sy_grado i.iddepartamento_cotiz edad edad2 male_fixed i.p_biologia_cat
                i.p_matematica_cat i.p_filosofia_cat i.p_fisica_cat i.p_quimica_cat i.p_lenguaje_cat
                i.p_ciencias_sociales_cat i.fami_ing_fmliar_mensual i.max_educa_SB11 i.idnucleo
                i.idmodalidad i.caracteries d_publica i.iddepartamento_ies
controls_d:     i.year i.sy_grado i.iddepartamento_cotiz edad edad2 male_fixed i.p_biologia_cat
                i.p_matematica_cat i.p_filosofia_cat i.p_fisica_cat i.p_quimica_cat i.p_lenguaje_cat
                i.p_ciencias_sociales_cat i.fami_ing_fmliar_mensual i.max_educa_SB11 i.idnucleo
                i.idmodalidad
controls_c:     i.year i.sy_grado i.iddepartamento_cotiz edad edad2 male_fixed i.p_biologia_cat
                i.p_matematica_cat i.p_filosofia_cat i.p_fisica_cat i.p_quimica_cat i.p_lenguaje_cat
                i.p_ciencias_sociales_cat i.fami_ing_fmliar_mensual i.max_educa_SB11
controls_b:     i.year i.sy_grado i.iddepartamento_cotiz edad edad2 male_fixed i.p_biologia_cat
                i.p_matematica_cat i.p_filosofia_cat i.p_fisica_cat i.p_quimica_cat i.p_lenguaje_cat
                i.p_ciencias_sociales_cat
saber11_c2:     p_biologia p_matematica p_filosofia p_fisica p_quimica p_lenguaje p_ciencias_sociales
                p_biologia2 p_matematica2 p_filosofia2 p_fisica2 p_quimica2 p_lenguaje2
                p_ciencias_sociales2
saber11:        i.p_biologia_cat i.p_matematica_cat i.p_filosofia_cat i.p_fisica_cat i.p_quimica_cat
                i.p_lenguaje_cat i.p_ciencias_sociales_cat
new_var_robust: new_program01_grad new_program03_grad new_program05_grad new_program00_mat
                new_program02_mat new_program04_mat new_program99_reg new_program01_reg new_program03_reg
options_new_SBpro:
                se br ar2 label nogaps modelwidth(7) drop() compress star(* 0.10 ** 0.05 *** 0.001)
                indicate("Exam Calendar=*prueba" "Demographics=edad edad2 male_fixed" "Deciles in ST Saber
                11=*p_lenguaje_cat *p_quimica_cat *p_fisica_cat *p_filosofia_cat *p_filosofia_cat
                *p_matematica_cat *p_ciencias_sociales_cat *p_biologia_cat" "Familly Inc. and Parents'
                Edu.=*ing_fmliar_mensual_SBpro *max_educa_SBpro" "High school FE=cole_codigo_colegio"
                "Degree= *idnucleo" "Duration of program=*idmodalidad" "Institution
                Characteristics=*caracteries d_publica" "HEI Region FE= *iddepartamento_ies" )
options_new:    se br ar2 label nogaps modelwidth(7) drop() compress star(* 0.10 ** 0.05 *** 0.001)
                indicate("Employment Region= *iddepartamento_cotiz" "Year and Graduation Date FE=*sy_grado
                *year" "Demographics=edad edad2 male_fixed" "Deciles in ST Saber 11=*p_lenguaje_cat
                *p_quimica_cat *p_fisica_cat *p_filosofia_cat *p_filosofia_cat *p_matematica_cat
                *p_ciencias_sociales_cat *p_biologia_cat" "Familly Inc. and Parents'
                Edu.=*fami_ing_fmliar_mensual *max_educa_SB11""High school FE=cole_codigo_colegio" "Degree=
                *idnucleo" "Duration of program=*idmodalidad" "Institution Characteristics=*caracteries
                d_publica" "HEI Region FE= *iddepartamento_ies" )
document:       /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//CMU/Paper
results:        /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//CMU/results
tools:          /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//CMU/tools/
SNIES:          /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//CMU/dataset/SNIES
log:            /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//CMU/do-files/log
tables:         /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//Aplicaciones/Overleaf//CMU/WBER
                > /tables
graphs:         /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//Aplicaciones/Overleaf//CMU/WBER
                > /graphs
dofiles:        /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//CMU/dofiles-WBER/Dofiles
datasets:       /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//CMU/dataset
data:           /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox//CMU/dofiles-WBER/Datasets
cd:             /Users/juanpablouribetrujillo/Library/CloudStorage/Dropbox/
S_MACH:         Macintosh (Intel 64-bit)
S_OSDTL:        14.4.1
S_OS:           MacOSX
S_StataSE:      SE
F8:             use
F7:             save
F2:             describe;
F1:             help advice;
S_level:        95
_title:         Baseline
_name:          cont
_time:          c.time
_keep_rule_after1992:
                if year>1992
_keep_rule_all: if 1==1
_listdiscrete:  ib2.periods dum Periods
_listcontinous2:
                c.time_+_c.time2 cont_2
_listcontinous: c.time cont Baseline
_tex_settigns:   prehead(\begin{table}[H]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
                \caption{@title} \setlength{\tabcolsep}{1pt} \begin{tabular}{l*{@span}{c}}\hline\hline)
                postfoot(\hline\hline \multicolumn{@span}{l}{\footnotesize Standard Errors in Parentheses
                Clustered at the State-Year Level. }\\ \multicolumn{@span}{l}{\footnotesize @starlegend. }
                \end{tabular}\end{table})
_pdf_plot_settings:
                scale(*1.5) ymtick(##4)
S_FN:           ../data/hpms_hwy_stats_88_08.dta
S_FNDATE:       16 May 2022 15:44

.            local cluster_var state_year;

.                 local tit_state "State";

.         local tit_state_year "State-year";

.         global SE_note "Standard Errors in Parentheses Clustered at the `tit_`cluster_var'' Level";

. if 1==1{;
.                 eststo ,prefix(OLS_): reg Diri  io0.I2_t   ,  cluster(`cluster_var');

Linear regression                               Number of obs     =    186,055
                                                F(1, 574)         =     261.19
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0659
                                                Root MSE          =     24.964

                           (Std. err. adjusted for 575 clusters in state_year)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      1.I2_t |  -32.66041   2.020894   -16.16   0.000    -36.62966   -28.69116
       _cons |   -.228283   .4031328    -0.57   0.571    -1.020078    .5635123
------------------------------------------------------------------------------
(OLS_1 stored)
.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797
.         eststo ,prefix(OLS_): reghdfe  Diri  io0.I2_t    ,  abs( state_year)  cluster(`cluster_var');
(dropped 1 singleton observations)
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   =    186,054
Absorbing 1 HDFE group                            F(   1,    573) =     263.49
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.2045
                                                  Adj R-squared   =     0.2021
                                                  Within R-sq.    =     0.0712
Number of clusters (state_year) =        574      Root MSE        =    23.0727

                           (Std. err. adjusted for 574 clusters in state_year)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      1.I2_t |  -31.94252   1.967828   -16.23   0.000    -35.80755   -28.07748
       _cons |  -.2594363   .0847296    -3.06   0.002    -.4258547   -.0930179
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
  state_year |       574         574           0    *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
(OLS_2 stored)
.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797
.                 eststo, prefix(OLS_) :reghdfe  Diri  io0.I2_t     , abs(id state_year)  cluster(`cluster_
> var') ;
(dropped 4820 singleton observations)
(MWFE estimator converged in 13 iterations)

HDFE Linear regression                            Number of obs   =    181,235
Absorbing 2 HDFE groups                           F(   1,    571) =     240.73
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.2547
                                                  Adj R-squared   =     0.1581
                                                  Within R-sq.    =     0.0782
Number of clusters (state_year) =        572      Root MSE        =    23.6644

                           (Std. err. adjusted for 572 clusters in state_year)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      1.I2_t |  -34.18256   2.203111   -15.52   0.000    -38.50975   -29.85537
       _cons |  -.1973883   .0944772    -2.09   0.037    -.3829535    -.011823
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
          id |     20221           0       20221     |
  state_year |       572         572           0    *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
(OLS_3 stored)
.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797
.                         eststo ,prefix(OLS_): reg Diri   io0.I2_t##(`time')   ,  cluster(`cluster_var');

Linear regression                               Number of obs     =    186,055
                                                F(3, 574)         =      91.94
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0666
                                                Root MSE          =     24.955

                           (Std. err. adjusted for 575 clusters in state_year)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      1.I2_t |  -39.32577   4.573468    -8.60   0.000    -48.30854     -30.343
        time |  -.0456806   .0694018    -0.66   0.511    -.1819931    .0906318
             |
 I2_t#c.time |
          1  |   .6945542   .4143397     1.68   0.094    -.1192526    1.508361
             |
       _cons |   .2384354   .9645693     0.25   0.805     -1.65608    2.132951
------------------------------------------------------------------------------
(OLS_4 stored)
.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797
.         eststo ,prefix(OLS_): reghdfe  Diri   io0.I2_t##(`time')   , abs(state)  cluster(`cluster_var');
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   =    186,055
Absorbing 1 HDFE group                            F(   3,    574) =      95.42
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0732
                                                  Adj R-squared   =     0.0729
                                                  Within R-sq.    =     0.0677
Number of clusters (state_year) =        575      Root MSE        =    24.8695

                           (Std. err. adjusted for 575 clusters in state_year)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      1.I2_t |  -39.31183   4.547104    -8.65   0.000    -48.24282   -30.38084
        time |  -.0368962   .0701504    -0.53   0.599     -.174679    .1008866
             |
 I2_t#c.time |
          1  |   .6666481   .4119037     1.62   0.106    -.1423742     1.47567
             |
       _cons |   .1598158   .9097316     0.18   0.861    -1.626993    1.946625
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
       state |        47           0          47     |
-----------------------------------------------------+
(OLS_5 stored)
. //texas omitted
>         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797
.                 eststo, prefix(OLS_): reghdfe Diri   io0.I2_t##(`time')  , abs(id )   cluster(`cluster_va
> r') ;
(dropped 4819 singleton observations)
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   =    181,236
Absorbing 1 HDFE group                            F(   3,    572) =      87.91
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1261
                                                  Adj R-squared   =     0.0163
                                                  Within R-sq.    =     0.0739
Number of clusters (state_year) =        573      Root MSE        =    25.5806

                           (Std. err. adjusted for 573 clusters in state_year)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      1.I2_t |  -43.28426   5.240045    -8.26   0.000    -53.57633   -32.99218
        time |  -.0214573   .0784415    -0.27   0.785    -.1755257    .1326111
             |
 I2_t#c.time |
          1  |   .8326941   .4695528     1.77   0.077    -.0895639    1.754952
             |
       _cons |   .0668691   1.002697     0.07   0.947    -1.902549    2.036287
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
          id |     20221           0       20221     |
-----------------------------------------------------+
(OLS_6 stored)
.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797
.         estfe . OLS_*, labels(state "State FE" state_year "State-Year FE" id "Segment id FE");
.         esttab OLS_* using "${output}/tables/TableB1_sample_regressions1_I2_t_SE`cluster_var'.tex", repla
> ce
>                 b(%8.2fc) se(%8.2fc)  
>                 star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 
>                 order( )
>                 title("Resurfacing and IRI \label{tab:IRI_resurfacing}")
>                 indicate(`r(indicate_fe)' )
>                 nomtitles  noomitted   nobaselevels 
>             scalars( "mean_Diri Mean \( \Delta Q_{st} \)"  "mean_aadt Mean AADT" ) 
>                 substitute(\_ _  "I2_t=1" "$ \mathds{1}_{ist}(q) $"
>                 "State FE" "\cline{2-7}State FE")
>                 se  par   r2 label nogaps  drop(_cons c1 ) compress
>         obslast stats(N, fmt(%15.0fc))
>                 ${prehead_start_longcol}
>                 `font_size'
>                 ${prehead_end}
>                 ${postfoot}             ;
(output written to ..//tables/TableB1_sample_regressions1_I2_t_SEstate_year.tex)
. };

.         eststo clear ;

.                 *IV Definition:;
.         *----------------------------;
.         *expenditure per resurfaced mile;
.         local IV I2_t_L4_apport_I2;

.         label var I2_t_L4_apport_I2 "\( \mathds{1}_{ist}(q)app_{s(t-4)} \right) \)";

.         gen `IV'Xtime =`IV'*time;

.         label var `IV'Xtime "\( \mathds{1}_{ist}(q)app_{s(t-4)} \right)  t \)";

.         gen `IV'_sample=1 if `IV'!=.;

.                         *expenditure per resurfaced mile;
.         sort id year ;

.                 eststo ,prefix(table_): reg Diri  c.I2_t_exp_I2  ,  cluster(`cluster_var');

Linear regression                               Number of obs     =    186,055
                                                F(1, 574)         =     254.76
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0578
                                                Root MSE          =     25.071

                           (Std. err. adjusted for 575 clusters in state_year)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
 I2_t_exp_I2 |  -619.2928   38.79958   -15.96   0.000    -695.4992   -543.0863
       _cons |  -.5522156   .4083745    -1.35   0.177    -1.354306    .2498751
------------------------------------------------------------------------------
(table_1 stored)

.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797

.         eststo ,prefix(table_): reghdfe Diri  c.I2_t_exp_I2  , abs( state_year )    cluster(`cluster_var'
> );
(dropped 1 singleton observations)
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   =    186,054
Absorbing 1 HDFE group                            F(   1,    573) =     254.70
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1975
                                                  Adj R-squared   =     0.1950
                                                  Within R-sq.    =     0.0630
Number of clusters (state_year) =        574      Root MSE        =    23.1743

                           (Std. err. adjusted for 574 clusters in state_year)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
 I2_t_exp_I2 |  -607.6037   38.07238   -15.96   0.000    -682.3821   -532.8252
       _cons |   -.572827    .066543    -8.61   0.000    -.7035249   -.4421291
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
  state_year |       574         574           0    *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
(table_2 stored)

.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797

.                         eststo, prefix(table_) : reghdfe Diri  c.I2_t_exp_I2    , abs(id state_year )   c
> luster(`cluster_var') ;
(dropped 4820 singleton observations)
(MWFE estimator converged in 13 iterations)

HDFE Linear regression                            Number of obs   =    181,235
Absorbing 2 HDFE groups                           F(   1,    571) =     237.83
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.2477
                                                  Adj R-squared   =     0.1502
                                                  Within R-sq.    =     0.0695
Number of clusters (state_year) =        572      Root MSE        =    23.7760

                           (Std. err. adjusted for 572 clusters in state_year)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
 I2_t_exp_I2 |  -646.1202   41.89683   -15.42   0.000    -728.4109   -563.8295
       _cons |  -.5342441   .0732094    -7.30   0.000    -.6780367   -.3904514
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
          id |     20221           0       20221     |
  state_year |       572         572           0    *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
(table_3 stored)

.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797

.                         eststo ,prefix(table_): reg Diri c.I2_t_exp_I2 time  I2_t_exp_I2Xtime   ,  cluste
> r(`cluster_var');

Linear regression                               Number of obs     =    186,055
                                                F(3, 574)         =      95.15
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0607
                                                Root MSE          =     25.033

                               (Std. err. adjusted for 575 clusters in state_year)
----------------------------------------------------------------------------------
                 |               Robust
            Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------+----------------------------------------------------------------
     I2_t_exp_I2 |  -921.0034    93.6992    -9.83   0.000    -1105.039   -736.9683
            time |  -.0226231   .0696963    -0.32   0.746     -.159514    .1142677
I2_t_exp_I2Xtime |   27.46207   7.008243     3.92   0.000     13.69714      41.227
           _cons |  -.2876144   .9718032    -0.30   0.767    -2.196338     1.62111
----------------------------------------------------------------------------------
(table_4 stored)

.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797

.         eststo ,prefix(table_): reghdfe    Diri  c.I2_t_exp_I2 time  I2_t_exp_I2Xtime   ,abs(state )   cl
> uster(`cluster_var');
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   =    186,055
Absorbing 1 HDFE group                            F(   3,    574) =      99.86
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0667
                                                  Adj R-squared   =     0.0665
                                                  Within R-sq.    =     0.0612
Number of clusters (state_year) =        575      Root MSE        =    24.9557

                               (Std. err. adjusted for 575 clusters in state_year)
----------------------------------------------------------------------------------
                 |               Robust
            Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------+----------------------------------------------------------------
     I2_t_exp_I2 |  -922.9134   92.91788    -9.93   0.000    -1105.414   -740.4129
            time |  -.0173815   .0696163    -0.25   0.803    -.1541151    .1193522
I2_t_exp_I2Xtime |   27.28897   6.894246     3.96   0.000     13.74795       40.83
           _cons |  -.3345711   .9051784    -0.37   0.712    -2.112437    1.443295
----------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
       state |        47           0          47     |
-----------------------------------------------------+
(table_5 stored)

. //texas omitted
>         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797

.         eststo, prefix(table_) : reghdfe  Diri  c.I2_t_exp_I2 time  I2_t_exp_I2Xtime   , abs(state_year )
>  cluster(`cluster_var') ;
(dropped 1 singleton observations)
note: time is probably collinear with the fixed effects (all partialled-out values are close to zero; tol =
>  1.0e-09)
(MWFE estimator converged in 1 iterations)
note: time omitted because of collinearity

HDFE Linear regression                            Number of obs   =    186,054
Absorbing 1 HDFE group                            F(   2,    573) =     141.91
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1999
                                                  Adj R-squared   =     0.1974
                                                  Within R-sq.    =     0.0658
Number of clusters (state_year) =        574      Root MSE        =    23.1395

                               (Std. err. adjusted for 574 clusters in state_year)
----------------------------------------------------------------------------------
                 |               Robust
            Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------+----------------------------------------------------------------
     I2_t_exp_I2 |  -892.0272   92.59722    -9.63   0.000    -1073.899   -710.1559
            time |          0  (omitted)
I2_t_exp_I2Xtime |   25.83204   6.924313     3.73   0.000     12.23191    39.43217
           _cons |   -.539672   .0660134    -8.18   0.000    -.6693297   -.4100143
----------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
  state_year |       574         574           0    *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
(table_6 stored)

.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797

.                 eststo, prefix(table_) : reghdfe  Diri  c.I2_t_exp_I2 time  I2_t_exp_I2Xtime   , abs(id )
>  cluster(`cluster_var') ;
(dropped 4819 singleton observations)
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   =    181,236
Absorbing 1 HDFE group                            F(   3,    572) =      89.83
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1195
                                                  Adj R-squared   =     0.0089
                                                  Within R-sq.    =     0.0669
Number of clusters (state_year) =        573      Root MSE        =    25.6770

                               (Std. err. adjusted for 573 clusters in state_year)
----------------------------------------------------------------------------------
                 |               Robust
            Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------+----------------------------------------------------------------
     I2_t_exp_I2 |  -992.8591    104.831    -9.47   0.000     -1198.76   -786.9585
            time |   .0002643    .078244     0.00   0.997    -.1534163    .1539448
I2_t_exp_I2Xtime |   29.95849   7.635774     3.92   0.000     14.96091    44.95606
           _cons |  -.4784594    1.00049    -0.48   0.633    -2.443541    1.486622
----------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
          id |     20221           0       20221     |
-----------------------------------------------------+
(table_7 stored)

.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797

.                 eststo, prefix(table_) : reghdfe  Diri  c.I2_t_exp_I2 time  I2_t_exp_I2Xtime   , abs(id s
> tate_year) cluster(`cluster_var') ;
(dropped 4820 singleton observations)
note: time is probably collinear with the fixed effects (all partialled-out values are close to zero; tol =
>  1.0e-09)
(MWFE estimator converged in 15 iterations)
note: time omitted because of collinearity

HDFE Linear regression                            Number of obs   =    181,235
Absorbing 2 HDFE groups                           F(   2,    571) =     129.00
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.2503
                                                  Adj R-squared   =     0.1532
                                                  Within R-sq.    =     0.0728
Number of clusters (state_year) =        572      Root MSE        =    23.7342

                               (Std. err. adjusted for 572 clusters in state_year)
----------------------------------------------------------------------------------
                 |               Robust
            Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------+----------------------------------------------------------------
     I2_t_exp_I2 |  -966.2195   104.0846    -9.28   0.000    -1170.655    -761.784
            time |          0  (omitted)
I2_t_exp_I2Xtime |   28.86735   7.693455     3.75   0.000     13.75642    43.97827
           _cons |  -.5025425   .0732045    -6.86   0.000    -.6463255   -.3587596
----------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
          id |     20221           0       20221     |
  state_year |       572         572           0    *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
(table_8 stored)

.         sum_stats;

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        Diri |    186,055   -1.634723    25.82929       -200        200

added scalar:
          e(mean_Diri) =  -1.6347232

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  aadt_10000 |    186,055    4.752439    4.709067       .004      41.18

added scalar:
          e(mean_aadt) =  4.7524393

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        I2_t |    186,055    .0430625    .2029985          0          1

added scalar:
          e(mean_I2_t) =  .04306254

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 I2_t_exp_I2 |    186,055     .001748    .0100308          0   .1689003

added scalar:
      e(mean_I2_t_exp) =  .00174797

.                 estfe . table_1 table_2 table_3 table_4 table_5 table_7   , labels(state "State FE" state
> _year "State-Year FE" id "Segment id FE");

.         return list;

macros:
        r(indicate_fe) : " "State FE=0.state"  "State-Year FE=0.state_year"  "Segment id FE=0.id" "

.                                 esttab table_1 table_2 table_3 table_4 table_5 table_7 using "${output}/t
> ables/Table2_sample_regressions.tex", replace
>                 b(%8.2fc) se(%8.2fc)  
>                 order( I2_t_exp_I2 time )
>                                 star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 
>                 title("Resurfacing expenditure and IRI\label{tab:IRI_expenditure}")
>                 
>                 indicate( `r(indicate_fe)')
>                 nomtitles  noomitted   nobaselevels  
>                 scalars( "mean_Diri Mean \( \Delta Q_{st} \)"  "mean_aadt Mean AADT"   ) 
>                 substitute(\_ _ "I2_t=1" "$\mathds{1}_{ist}(q)$"
>                                         "State FE" "\cline{2-7}State FE")
>                 se  par  r2 label nogaps drop(_cons c1) compress
>         obslast stats(N , fmt(%15.0fc)  labels(`"N"' ))
>                 `tex_settigns'
>                 ;
(output written to ..//tables/Table2_sample_regressions.tex)

.         eststo clear;

.         *-----------------------------------;
. * - I_t on IRI ;
.  *-----------------------------------;
. ren I2_t_x* I2_t_x_T* ;

. eststo: reg Diri  I2_t_x_T*  ,  cluster(state) ;

Linear regression                               Number of obs     =    186,055
                                                F(17, 46)         =      23.93
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0707
                                                Root MSE          =     24.901

                                 (Std. err. adjusted for 47 clusters in state)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
I2_t_x_T1992 |  -25.23841   5.730878    -4.40   0.000    -36.77407   -13.70275
I2_t_x_T1993 |  -28.07136    7.43566    -3.78   0.000    -43.03856   -13.10415
I2_t_x_T1994 |   -33.6003   6.443713    -5.21   0.000    -46.57082   -20.62978
I2_t_x_T1995 |  -39.72914   8.157089    -4.87   0.000     -56.1485   -23.30977
I2_t_x_T1996 |  -42.49199   7.630125    -5.57   0.000    -57.85064   -27.13335
I2_t_x_T1997 |  -39.90027    4.57738    -8.72   0.000    -49.11406   -30.68648
I2_t_x_T1998 |  -51.72379   8.968452    -5.77   0.000    -69.77635   -33.67124
I2_t_x_T1999 |  -31.97835   4.863691    -6.57   0.000    -41.76845   -22.18825
I2_t_x_T2000 |  -28.05409   5.790439    -4.84   0.000    -39.70964   -16.39854
I2_t_x_T2001 |  -30.38041   4.469983    -6.80   0.000    -39.37802    -21.3828
I2_t_x_T2002 |  -18.30483     5.1185    -3.58   0.001    -28.60784   -8.001824
I2_t_x_T2003 |  -31.08492   4.889586    -6.36   0.000    -40.92714   -21.24269
I2_t_x_T2004 |  -20.75554   4.098049    -5.06   0.000    -29.00449    -12.5066
I2_t_x_T2005 |  -34.72425   5.159989    -6.73   0.000    -45.11077   -24.33773
I2_t_x_T2006 |  -29.93698   4.889658    -6.12   0.000    -39.77936   -20.09461
I2_t_x_T2007 |  -34.32162   11.29457    -3.04   0.004    -57.05641   -11.58682
I2_t_x_T2008 |  -19.63427    8.41051    -2.33   0.024    -36.56375   -2.704797
       _cons |   -.228283    .332015    -0.69   0.495    -.8965946    .4400286
------------------------------------------------------------------------------
(est1 stored)

. plot_dummies;
(file se.dta not found)
file se.dta saved

beta[1,18]
    I2_t_x_T1992  I2_t_x_T1993  I2_t_x_T1994  I2_t_x_T1995  I2_t_x_T1996  I2_t_x_T1997  I2_t_x_T1998
y1    -25.238413    -28.071358    -33.600298    -39.729136    -42.491995    -39.900267    -51.723795

    I2_t_x_T1999  I2_t_x_T2000  I2_t_x_T2001  I2_t_x_T2002  I2_t_x_T2003  I2_t_x_T2004  I2_t_x_T2005
y1    -31.978352    -28.054091    -30.380413     -18.30483    -31.084916    -20.755544    -34.724249

    I2_t_x_T2006  I2_t_x_T2007  I2_t_x_T2008         _cons
y1    -29.936983    -34.321617    -19.634275    -.22828304
Number of observations (_N) was 0, now 1.
number of observations will be reset to 1
Press any key to continue, or Break to abort
Number of observations (_N) was 0, now 1.
(j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   18          
Number of variables                  19   ->   3           
j variable (18 values)                    ->   year
xij variables:
                 beta1 beta2 ... beta18   ->   beta
-----------------------------------------------------------------------------

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                                18  (_merge==3)
    -----------------------------------------
(1 observation deleted)
(0 observations deleted)
(0 observations deleted)
variable year was byte now int
(17 real changes made)
(file beta.dta not found)
file beta.dta saved
(note:  named style med not found in class gsize, default attributes used)
file /Users/juanpablouribetrujillo/My Drive
    (jp.uribe86@gmail.com)/Research/MyPapers/MTU/JUE/analysis/temp_t.pdf saved as PDF format
(file temp_betas.dta not found)
file temp_betas.dta saved

. copy "temp_t.pdf" "${output}/figures/FigureB1_year_X_I2_1.pdf", replace;

. erase "temp_t.pdf";

. erase "temp_betas.dta";

. ren  I2_t_x_T* I2_t_x*;

. ren I2_t_*_exp_I2 I2_t_x_T* ;

. eststo: reg Diri  I2_t_x_T*  ,  cluster(state) ;

Linear regression                               Number of obs     =    186,055
                                                F(17, 46)         =      62.18
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0630
                                                Root MSE          =     25.004

                                 (Std. err. adjusted for 47 clusters in state)
------------------------------------------------------------------------------
             |               Robust
        Diri | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
I2_t_x_T1992 |  -738.7121   218.3091    -3.38   0.001    -1178.145   -299.2788
I2_t_x_T1993 |  -823.8507   197.2526    -4.18   0.000      -1220.9   -426.8017
I2_t_x_T1994 |  -639.1332   74.56415    -8.57   0.000     -789.223   -489.0433
I2_t_x_T1995 |  -850.1246   118.6365    -7.17   0.000    -1088.928   -611.3216
I2_t_x_T1996 |  -993.2989    147.752    -6.72   0.000    -1290.708   -695.8895
I2_t_x_T1997 |  -740.7926    123.175    -6.01   0.000    -988.7311   -492.8541
I2_t_x_T1998 |   -991.707   354.7305    -2.80   0.008    -1705.742   -277.6716
I2_t_x_T1999 |  -574.5139   78.53398    -7.32   0.000    -732.5946   -416.4332
I2_t_x_T2000 |  -612.6736   120.7909    -5.07   0.000     -855.813   -369.5342
I2_t_x_T2001 |  -659.8079   166.9955    -3.95   0.000    -995.9525   -323.6633
I2_t_x_T2002 |  -445.5163   82.35816    -5.41   0.000    -611.2947   -279.7379
I2_t_x_T2003 |  -612.2792   77.20093    -7.93   0.000    -767.6767   -456.8818
I2_t_x_T2004 |  -385.0585   47.40012    -8.12   0.000      -480.47    -289.647
I2_t_x_T2005 |  -672.9983   104.9829    -6.41   0.000    -884.3179   -461.6787
I2_t_x_T2006 |  -484.3684   73.29631    -6.61   0.000    -631.9062   -336.8305
I2_t_x_T2007 |  -484.7732   84.15449    -5.76   0.000    -654.1674    -315.379
I2_t_x_T2008 |  -368.2157   115.8637    -3.18   0.003    -601.4373   -134.9941
       _cons |  -.5086047   .2957686    -1.72   0.092    -1.103956    .0867466
------------------------------------------------------------------------------
(est2 stored)

. plot_dummies;
(file se.dta not found)
file se.dta saved

beta[1,18]
    I2_t_x_T1992  I2_t_x_T1993  I2_t_x_T1994  I2_t_x_T1995  I2_t_x_T1996  I2_t_x_T1997  I2_t_x_T1998
y1     -738.7121    -823.85066    -639.13316    -850.12459    -993.29886    -740.79259    -991.70703

    I2_t_x_T1999  I2_t_x_T2000  I2_t_x_T2001  I2_t_x_T2002  I2_t_x_T2003  I2_t_x_T2004  I2_t_x_T2005
y1    -574.51388    -612.67363    -659.80788    -445.51632    -612.27924    -385.05855    -672.99834

    I2_t_x_T2006  I2_t_x_T2007  I2_t_x_T2008         _cons
y1    -484.36836    -484.77321    -368.21567    -.50860467
Number of observations (_N) was 0, now 1.
number of observations will be reset to 1
Press any key to continue, or Break to abort
Number of observations (_N) was 0, now 1.
(j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations                1   ->   18          
Number of variables                  19   ->   3           
j variable (18 values)                    ->   year
xij variables:
                 beta1 beta2 ... beta18   ->   beta
-----------------------------------------------------------------------------

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                                18  (_merge==3)
    -----------------------------------------
(1 observation deleted)
(0 observations deleted)
(0 observations deleted)
variable year was byte now int
(17 real changes made)
(file beta.dta not found)
file beta.dta saved
file /Users/juanpablouribetrujillo/My Drive
    (jp.uribe86@gmail.com)/Research/MyPapers/MTU/JUE/analysis/temp_t.pdf saved as PDF format
(file temp_betas.dta not found)
file temp_betas.dta saved

. copy "temp_betas.dta" "../intermediate_data/resurf_betas_1.dta", replace ;

. erase "temp_t.pdf";

. erase "temp_betas.dta";

. ren  I2_t_x_T* I2_t_*_exp_I2;

. log close;
      name:  <unnamed>
       log:  /Users/juanpablouribetrujillo/My Drive (jp.uribe86@gmail.com)/Research/MyPapers/MTU/JUE/analys
> is/../logs/sample_regressions.log
  log type:  text
 closed on:  24 Jun 2024, 22:23:15
-----------------------------------------------------------------------------------------------------------
